GIF en- and decoding library
GIF en- and decoder written in Rust (API Documentation).
GIF encoding and decoding library
This library provides all functions necessary to de- and encode GIF files.
High level interface
The high level interface consists of the two types
Encoder
and Decoder
.
They as builders for the actual en- and decoders and can be used to set various
options beforehand.
Decoding GIF files
// Open the file
use File;
use SetParameter;
let mut decoder = new;
// Configure the decoder such that it will expand the image to RGBA.
decoder.set;
// Read the file header
let mut decoder = decoder.read_info.unwrap;
while let Some = decoder.read_next_frame.unwrap
Encoding GIF files
The encoder can be used so save simple computer generated images:
use ;
use File;
use Cow;
let color_map = &;
let = ;
let mut beacon_states = ;
let mut image = create.unwrap;;
let mut encoder = new.unwrap;
encoder.set.unwrap;
for state in &beacon_states
Frame::from_*
can be used to convert a true color image to a paletted
image with a maximum of 256 colors:
use File;
// Get pixel data from some source
let mut pixels: = vec!;
// Create frame from data
let frame = from_rgb;
// Create encoder
let mut image = create.unwrap;
let mut encoder = new.unwrap;
// Write frame to file
encoder.write_frame.unwrap;